/**
 * @file   ResponseStatus.h
 * @author Djuro Drljaca (djurodrljaca@gmail.com)
 * @date   2014-04-26
 * @brief  DON response status enum and it's supporting functions.
 *
 * Copyright 2014  Djuro Drljaca (djurodrljaca@gmail.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef DON_CORE_PACKET_RESPONSESTATUS_H
#define DON_CORE_PACKET_RESPONSESTATUS_H

#include <QtCore/qglobal.h>
#include <DON/Core/libdon-qt4-core_global.h>

namespace DON
{
namespace Core
{
namespace Packet
{

/**
 * @brief Enumerates all response statuses
 */
enum ResponseStatus
{
    ResponseStatus_Invalid = -1,
    ResponseStatus_Success = 0,
    ResponseStatus_GeneralError = 1,
    ResponseStatus_AddressError = 2,
    ResponseStatus_ParameterError = 3,
    ResponseStatus_AccessDenied = 4,

    ResponseStatus_ErrorCode255 = 255
};

/**
 * @brief Check if response status is valid
 * @param responseStatus Response status
 * @retval true Response status is valid
 * @retval false Response status is not valid
 */
LIBDONQT4CORESHARED_EXPORT bool isResponseStatusValid(const ResponseStatus responseStatus);

/**
 * @brief Convert binary data to ResponseStatus value
 * @param data Binary data
 * @param ok Error status output (true --> success, false --> error)
 * @return ResponseStatus value
 */
LIBDONQT4CORESHARED_EXPORT ResponseStatus fromBinaryToResponseStatus(const char data);

/**
 * @brief Convert ResponseStatus value to binary data
 * @param responseStatus ResponseStatus value
 * @param ok Error status output (true --> success, false --> error)
 * @return Binary data
 */
LIBDONQT4CORESHARED_EXPORT char fromResponseStatusToBinary(const ResponseStatus responseStatus,
                                                           bool *ok = NULL);

}
}
}

#endif // DON_CORE_PACKET_RESPONSESTATUS_H
